# coding=utf-8

import subprocess
from sys_intd.commands import list_cmd, start, stop, install, search, info, uninstall

class CmdExcutor:

    @staticmethod
    def execute(msg: dict):
        try:
            func_str = msg.pop("command")
            func = eval(func_str)
            func_res = func(**msg)
            if not func_res:
                func_res = [f"{func_str} command return None."]
            response = {"status": "success",
                        "message": func_res}
        except Exception as e:
            import traceback
            print(traceback.print_exc())
            response = {"status": "error", "message": [f"{e}"]}

        return response

